package pay;

import java.util.Scanner;

public class TopCall {
	
	Scanner in = new Scanner(System.in);
	
	public void pay() {
		System.out.println("请选择您的服务:1-支付，2-银行卡绑定");
		int x = in.nextInt();
		switch(x){
			case 1:{
				ServerUser user = new ServerUser();
				System.out.println("请输入购买类型:1-会员购买，2-商品购买");
				int choice1 = in.nextInt();
				switch(choice1) {
					case 1:{
						double price1 = 18;
						double price2 = 40;
						System.out.println("请选择会员类型：1-一个月黑胶vip，2-一个月黑胶svip");
						int choice2 = in.nextInt();
						if (choice2 == 1) {
							System.out.println("您需要支付的金额为："+price1);
							Wallet wallet = new Wallet();
							System.out.println("请输入支付类型：银行卡/零钱");
							String type = in.next();
							type += in.nextLine();
							wallet.pay(type,price1);
						}
						else if(choice2 == 2) {
							System.out.println("您需要支付的金额为："+price2);
							Wallet wallet = new Wallet();
							System.out.println("请输入支付类型：银行卡/零钱");
							String type = in.next();
							type += in.nextLine();
							wallet.pay(type,price2);
						}
						else {
							System.out.println("非法输入！");
							System.exit(1);
						}
						break;
					}
					case 2:{
						System.out.println("请输入商品价格：");
						double price = in.nextInt();
						double newprice = 0;
						System.out.println("请选择是否使用优惠：1-使用普通会员优惠，2-使用高级会员优惠，3不使用优惠");
						int choice = in.nextInt();
						if (choice == 1) {
							DiscountStrategy smallstrategy = new SmallDiscount();
							newprice = user.buy(price, smallstrategy);
						}
						else if(choice == 2) {
							DiscountStrategy largestrategy = new LargeDiscount();
							newprice = user.buy(price, largestrategy);
						}
						else if(choice == 3) {
							newprice = price;
						}
						else {
							System.out.println("非法输入！");
							System.exit(1);
						}
						System.out.println("您需要支付的金额为："+newprice);
						Wallet wallet = new Wallet();
						System.out.println("请输入支付类型：银行卡/零钱");
						String type = in.next();
						type += in.nextLine();
						wallet.pay(type,newprice);
						break;
					}
					default:
						System.out.println("非法输入!");
				}
				break;
			}
			case 2:{
				BankCardFactory bankfactory = new BankCardFactory();
				BankCard bankcard = null;
				System.out.println("请选择绑定：:1-农业银行卡，2-中国银行卡，3-交通银行卡");
				int choice = in.nextInt();
				switch(choice) {
				case 1:{
					bankcard = bankfactory.getCard("agriculturalbankcard");
					break;
					}
				case 2:{
					bankcard = bankfactory.getCard("chinabankcard");
					break;
					}
				case 3:{
					bankcard = bankfactory.getCard("communicationsbankcard");
					break;
					}
				default:
					System.out.println("非法输入!");
					System.exit(1);
				}
				bankcard.bind();
				break;
			}
			default:System.out.println("非法输入!");
					System.exit(1);
		}
	}
}
